package cj.web.portal.dao;

import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.ReturnGeneratedKeys;
import net.paoding.rose.jade.annotation.SQL;

@DAO
public interface MemberVoDAO {

	@ReturnGeneratedKeys
	@SQL("INSERT INTO Member(id,phone,pwd,sex,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES(:3,:1,:2,0,1,:1,NOW(),:1,NOW())")
	int register(String phone,String pwd,Integer id);
	
	@SQL("UPDATE Member SET pwd=:2 WHERE deleteFlag=1 AND id=:1 ")
	void updateMemberId(int memberId,String pwd);
	
	@SQL("UPDATE Member SET point=point+ (:2) WHERE id=:1 ")
	void updateMemberPoint(int memberId,int point);
	
	@SQL("UPDATE Member SET name=:2,age=:3,sex=:4,career=5 WHERE deleteFlag=1 AND id=:1 ")
	void updateMemberId(int memberId,String name,String age,String sex,String career);
	
	@SQL("SELECT count(0) FROM Member WHERE deleteFlag=1 AND phone LIKE '%##(:1)%' ")
	int isRegister(String phone);
	
	@SQL("SELECT * FROM Member WHERE deleteFlag=1 AND phone LIKE '%##(:1)%' ")
	List<Map> getMemberByPhone(String phone);
	
	@SQL("SELECT * FROM Member WHERE deleteFlag=1 AND id=:1 ")
	List<Map> getMemberById(int id);
	
	@SQL("SELECT id FROM Member WHERE deleteFlag=1 AND phone LIKE '%##(:1)%' ")
	int getBuyerId(String phone);
	
	@SQL("SELECT phone FROM Member WHERE id=:1 ")
	String getPhoneById(int id);
	
	@SQL("SELECT id,phone,name,point,career FROM Member WHERE deleteFlag=1 AND type=0 ORDER BY point DESC LIMIT :1,:2 ")
	List<Map> getMemberAll(int start,int length);
}
